$(function() {
	var allorder = echarts.init(document.getElementById('allorder'));
	var allmoneny = echarts.init(document.getElementById('allmoneny'));
	var alltime = echarts.init(document.getElementById('alltime'));
	$(this).removeClass('am-btn-secondary')
	$('.timeclassify>button').on('click', function() {
		$('.time').val($(this).data('val'))
	})

	option = {
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b}: {c} ({d}%)"
		},
		legend: {
			orient: 'vertical',
			x: 'left',
			data: [
			{foreach $types as $key => $type}
			'{$type}',
			{/foreach}
			'']
		},
		series: [{
			name: '订单数量',
			type: 'pie',
			radius: ['50%', '70%'],
			avoidLabelOverlap: false,
			label: {
				normal: {
					show: false,
					position: 'center'
				},
				emphasis: {
					show: true,
					textStyle: {
						fontSize: '24',
						fontWeight: 'bold'
					}
				}
			},
			labelLine: {
				normal: {
					show: false
				}
			},
			data: [
				{foreach $types as $key => $type}
				{
					value: {$qty[$key]?$qty[$key]:0},
					name: '{$type}'
				},
				{/foreach}
				{}
			]
		}]
	};

	option1 = {
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b}: {c} ({d}%)"
		},
		legend: {
			orient: 'vertical',
			x: 'left',
			data: [
			{foreach $types as $key => $type}
			'{$type}',
			{/foreach}
			'']
		},
		series: [{
			name: '金额',
			type: 'pie',
			radius: ['50%', '70%'],
			avoidLabelOverlap: false,
			label: {
				normal: {
					show: false,
					position: 'center'
				},
				emphasis: {
					show: true,
					textStyle: {
						fontSize: '24',
						fontWeight: 'bold'
					}
				}
			},
			labelLine: {
				normal: {
					show: false
				}
			},
			data: [
			{foreach $types as $key => $type}
				{
					value: {$price[$key]?$price[$key]:0},
					name: "{$type}"
				},
					{/foreach}
				{}
			]
		}]
	};
	option2 = {
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b}: {c} ({d}%)"
		},
		legend: {
			orient: 'vertical',
			x: 'left',
			data: [
			{foreach $types as $key => $type}
			'{$type}',
			{/foreach}
			'']
		},
		series: [{
			name: '耗时',
			type: 'pie',
			radius: ['50%', '70%'],
			avoidLabelOverlap: false,
			label: {
				normal: {
					show: false,
					position: 'center'
				},
				emphasis: {
					show: true,
					textStyle: {
						fontSize: '24',
						fontWeight: 'bold'
					}
				}
			},
			labelLine: {
				normal: {
					show: false
				}
			},
			data: [
				{foreach $types as $key => $type}
				{
					value: {$time[$key]?$time[$key]:0},
					name: "{$type}"
				},
					{/foreach}
				{}
				
			]
		}]
	};

	// 使用刚指定的配置项和数据显示图表。
	allorder.setOption(option);
	allmoneny.setOption(option1);
	alltime.setOption(option2);
	
//		$('.report-classify>button').on('click', function() {
//			$(this).removeClass('am-btn-secondary')
//			$(this).addClass('am-btn-success')
//			$(this).siblings().removeClass('am-btn-success')
//			$(this).siblings().addClass('am-btn-secondary')
//		})
		
	$('.endtime').on('change',function(){
		datejudge($('.begintime'),$('.endtime'))
	})
	$('.begintime').on('change',function(){
		datejudge($('.begintime'),$('.endtime'))
	})

})